home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
xlib.zip
/
XCOLLECT.INT
< prev
next >
Wrap
Text File
|
1992-09-06
|
6KB
|
150 lines
(*****************************************************************************)
(* *)
(* Filename : XCOLLECT.PAS *)
(* Autor : Stefan Boether / Compuserve Id : 100023,275 *)
(* FidoNet : 2:242/200 *)
(* FidoNet : 2:243/91 *)
(* Internet: 100023.275@CompuServe.COM *)
(* System : TURBO 6.01 / MS-DOS / TPW 1.5 / WIN 3.1 *)
(* Aenderung : *)
(* wann was wer *)
(*---------------------------------------------------------------------------*)
(* 26.04.92 Added OverFlowCollection Stefc *)
(* 05.08.92 Added TStrCollection Stefc *)
(* 16.08.92 New "LookAHead" method for FiFo/LiFo Stacks Stefc *)
(* 18.08.92 Rename unitname to XCOLLECT Stefc *)
(* 29.08.92 Add the "TSingleCollection" to it Stefc *)
(* 30.08.92 Get Ready for TPW Stefc *)
(*****************************************************************************)
(* Beschreibung: Implements some Collections Types for TV-OWL *)
(*****************************************************************************)
{Header-End}
UNIT XCollect;
{$IfnDef Windows } {$O+} {$Endif}
{$D-}
INTERFACE
USES {$IFDEF Windows}
(* Z:OWL\ *) WObjects;
{$ELSE}
(* Y:TVISION\ *) Objects; (* Base-Objects and Collections *)
{$ENDIF}
TYPE { A Stack for First-In / First-Out access }
PFiFoCollection = ^TFiFoCollection;
TFiFoCollection = object( TCollection )
procedure Push( P : Pointer ); virtual;
function Pop : Pointer; virtual;
function LookAHead:Pointer; virtual;
end;
{ A Stack for Last-In / First-Out access }
PLiFoCollection = ^TLiFoCollection;
TLiFoCollection = object( TFiFoCollection )
function Pop : Pointer; virtual;
function LookAHead:Pointer; virtual;
end;
{ Used in TIntegerCollections }
PIntegerItem = ^TIntegerItem;
TIntegerItem = object ( TObject )
Item : Integer;
constructor Init( AItem: Integer );
end;
{ A sorted Collection for TIntegerItem objects }
PIntegerCollection = ^TIntegerCollection;
TIntegerCollection = object ( TSortedCollection )
function Compare(Key1, Key2: Pointer): Integer; virtual;
function KeyOf(Item: Pointer): Pointer; virtual;
end;
{ This collection you can use for buffers where after
a number of items the oldest would be delete automatically }
POverflowCollection = ^TOverFlowCollection;
TOverflowCollection = object ( TCollection )
MaxItems : Integer;
constructor Init( ALimit,ADelta,AMax: Integer );
procedure Insert( Item:Pointer ); virtual;
end;
{ The TStrCollection handle PString items in the same manner than
PStringCollection, but unsorted ! }
PStrCollection = ^TStrCollection;
TStrCollection = object( TCollection )
procedure FreeItem(Item: Pointer); virtual;
function GetItem(var S: TStream): Pointer; virtual;
procedure PutItem(var S: TStream; Item: Pointer); virtual;
procedure Writeln;
end;
{ The TPtrCollection can be used internal to collect
other Objects in memory like Windows }
PPtrCollection = ^TPtrCollection;
TPtrCollection = object( TCollection )
procedure FreeItem(Item: Pointer); virtual;
function GetItem(var S: TStream): Pointer; virtual;
procedure PutItem(var S: TStream; Item: Pointer); virtual;
end;
{ This is a special Collection that can be used instead
of single linked lists ! }
PSingleCollection = ^TSingleCollection;
TSingleCollection = object( TObject )
Normal : Boolean;
Next : PSingleCollection;
constructor Init( ANext:PSingleCollection );
destructor Done; virtual;
constructor Load(var S:TStream);
procedure Store(var S:TStream);
function Count:Word;
procedure ForEach(Action:Pointer);
procedure CopyTo( ACollection:PCollection );
end;
CONST RFiFoCollection : TStreamRec =
( ObjType: 20020;
VmtLink: Ofs(TypeOf(TFifoCollection)^);
Load: @TFifoCollection.Load;
Store: @TFifoCollection.Store
);
RLiFoCollection : TStreamRec =
( ObjType: 20021;
VmtLink: Ofs(TypeOf(TLiFoCollection)^);
Load: @TLiFoCollection.Load;
Store: @TLiFoCollection.Store
);
ROverflowCollection : TStreamRec =
( ObjType: 20022;
VmtLink: Ofs(TypeOf(TOverflowCollection)^);
Load: @TOverflowCollection.Load;
Store: @TOverflowCollection.Store
);
RStrCollection : TStreamRec =
( ObjType: 20023;
VmtLink: Ofs(TypeOf(TStrCollection)^);
Load: @TStrCollection.Load;
Store: @TStrCollection.Store
);
RSingleCollection: TStreamRec =
( ObjType: 20024;
VmtLink: Ofs(TypeOf(TSingleCollection)^);
Load: @TSingleCollection.Load;
Store: @TSingleCollection.Store
);
PROCEDURE RegisterXCollect;